package Behavioral.Strategy.demo2;

import Behavioral.Strategy.demo1.Context;
import Behavioral.Strategy.demo1.StrategyA;
import Behavioral.Strategy.demo1.StrategyB;

import java.util.Arrays;

/*策略模式也有缺点，比如客户端必须知道所有的策略类，并且知道这些类区别，以便选择恰当的策略类。*/
public class StrategyDemo2 {
	public static void main(String[] args) {
		Cat[] cats = {new Cat(5, 5), new Cat(1, 1), new Cat(3, 3)};

		Sorter.sort(cats, new CatWeightComparatorASC());
		System.out.println(Arrays.toString(cats));

		Sorter.sort(cats, new CatWeightComparatorDESC());
		System.out.println(Arrays.toString(cats));

		Sorter.sort(cats, ((o1, o2) -> {
			return Integer.compare(o1.height, o2.height);
		}));
		System.out.println(Arrays.toString(cats));
	}
}
